#pragma once

#include "CpUtil.h"

namespace CppClean
{

typedef CCpAutoPtr<CToken> CTokenPtr;
typedef CToken::TOKEN_LIST CTokenList;
typedef CCpAutoPtr<CCpObject> CObjectPtr;

class CAstBuilder
{
public:
	CAstBuilder(CTokenizer* pTokenizer, string sInClassName, 
		int eVisibility = VISIBILITY_NONE, const STRINGLIST& np = STRINGLIST());
	~CAstBuilder(void);

public:
	CObjectPtr GenerateOne();

private:
	CTokenPtr GetVarTokensUpTo(int eExpectedType, LPCSTR szExpectedTokens, CTokenList& aTokens);
	CTokenPtr GetNextToken();
	void AddBackToken(CTokenPtr pToken);
	void AddBackTokens(CTokenList aTokens);
	CObjectPtr _GenerateOne(CTokenPtr pToken);
	CObjectPtr HandleKeyword(const string& name);
	CCpAutoPtr<CClass> HandleClass();

protected:
	CTokenizer* m_pTokenizer;
	STRINGLIST m_aNameSpaces;
	CTokenList m_aTokenQues;
	string m_sInClassName;
	string m_sCurrentClassName;
	int m_eVisibility;
	CTokenPtr m_pCurrentToken;
	BOOL m_bHandlingTypeDef;
	BOOL m_bInFunction;
	CCpAutoPtr<CTypeConverter> m_pConverter;
};

}
